import { IRequestOption } from '@jl/common/composable';
import { request } from '@jl/common/utils';
import { IResource } from './types';

/**
 * 资源列表多条件查询
 * @param requestOption - 请求参数
 * @returns
 */
export const getResourceListByCond = (
  requestOption: IRequestOption<any, any>
): Promise<API.Base.ResponsePage<IResource>> => {
  return request({
    url: `/api/BasOpe/GetResListByMuCond`,
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 资源列表查询无分页
 * @param requestOption - 请求参数
 * @returns
 */

export const getResourceListByCondNoPage = (
  requestOption: IRequestOption<any, any>
): Promise<API.Base.ResponsePage<IResource>> => {
  return request({
    url: `/api/BasOpe/GetResListByMuCond/`,
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 资源列表无条件查询
 * @param requestOption - 请求参数
 * @returns
 */
export const getResourceList = (
  requestOption: IRequestOption<any, any>
): Promise<API.Base.ResponsePage<IResource>> => {
  return request({
    url: `/api/BasOpe/GetResList/${requestOption.params.pageSize}/${requestOption.params.index}`,
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 资源新增
 * @param requestOption - 请求参数
 * @returns
 */
export const addResource = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    // url: `/api/BasOpe/ResourceUploadParam`,
    url: '/api/BasOpe/api/resource/resUploadParam',
    method: 'POST',
    ...requestOption,
  });
};

/**
 * 资源编辑
 * @param requestOption - 请求参数
 * @returns
 */
export const updateResource = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/resource/editRecord`,
    method: 'PUT',
    ...requestOption,
  });
};

/**
 * 资源删除
 * @param requestOption - 请求参数
 * @returns
 */
export const deleteResource = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/resource/delRecord`,
    method: 'DELETE',
    ...requestOption,
  });
};

/**
 * 资源详情
 * @param requestOption - 请求参数
 * @returns
 */
export const getResourceDetail = (requestOption: IRequestOption<any, any>): Promise<IResource> => {
  return request({
    url: `/api/resource/getRecord`,
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 查询资源上传进度
 */
export const getResourceUploadProgress = (
  requestOption: IRequestOption<any, any>
): Promise<any> => {
  return request({
    url: '/api/BasOpe/GetUploadProg',
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 查询资源处理进度
 */
export const getResourceDisposeProgress = (
  requestOption: IRequestOption<any, any>
): Promise<any> => {
  return request({
    url: '/api/BasOpe/GetResourceProg',
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 资源新增 大文件  上传资源参数
 * @param requestOption - 请求参数
 * @returns
 */
export const resUploadParam = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/resource/resUploadParam`,
    method: 'POST',
    ...requestOption,
  });
};
/**
 * 处理失败，重试
 * @param requestOption - 请求参数
 * @returns
 */
export const reProcess = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/resource/reProcess`,
    method: 'PUT',
    ...requestOption,
  });
};

/**
 * 资源新增 大文件  覆盖上传
 * @param requestOption - 请求参数
 * @returns
 */
export const replaceRecord = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/resource/replaceRecord`,
    method: 'PUT',
    ...requestOption,
  });
};
/**
 * 资源新增 大文件列表数获取
 * @param requestOption - 请求参数
 * @returns
 */
export const getLocalUploadFiles = (): Promise<any> => {
  return request({
    url: `/api/resource/getLocalUploadFiles`,
    method: 'GET',
  });
};

/**
 * 处理本地文件
 */
export const handleLocalFile = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/resource/handleLoaclFile`,
    method: 'PUT',
    ...requestOption,
  });
};

/**
 * 添加资源访问次数
 */
export const insertResourceViewCount = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: '/api/resource/addUsageCount',
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 获取资源分类详细信息
 * @param
 */
export const getResourceCategoryTree = (): Promise<any> => {
  return request({
    url: '/api/BasOpe/getResourceCategoryTree',
    method: 'GET',
  });
};

/**
 * 获取资源分类详细信息带条件
 * @param
 */
export const getResourceListByCategory = (
  requestOption: IRequestOption<any, any>
): Promise<any> => {
  return request({
    url: '/api/BasOpe/getResourceListByCategory',
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 新增资源分类
 */
export const createResourceCategory = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: '/api/resource/createResourceCategory',
    method: 'POST',
    ...requestOption,
  });
};

/**
 * 删除资源分类
 */
export const delResourceCategory = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: '/api/resource/delResourceCategory',
    method: 'DELETE',
    ...requestOption,
  });
};
/**
 * 删除资源分类
 */
export const editResourceCategory = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: '/api/resource/editResourceCategory',
    method: 'PUT',
    ...requestOption,
  });
};

/**
 * 拖动排序
 */
export const updateOrderResourceCategory = (
  requestOption: IRequestOption<any, any>
): Promise<any> => {
  return request({
    url: '/api/resource/updateOrderResourceCategory',
    method: 'PUT',
    ...requestOption,
  });
};

/**
 * 资源文移动到其他分类
 */
export const dragResourceCategory = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: '/api/resource/dragResourceCategory',
    method: 'PUT',
    ...requestOption,
  });
};

/**
 * 下载
 */
export const downloadRsourceFile = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: '/api/resource/downloadRsourceFile',
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 获取分类
 */
export const getAdminRegsList = (params: any): Promise<IResource> => {
  return request({
    url: `/api/btmPlate/getResoCategoryIds`,
    method: 'GET',
    params,
  });
};

/**
 * 获取初始模型树
 */
export const getInitModTree = (params: { resId: string; resAddre: string }): Promise<any> => {
  return request({
    url: `/api/resource/getInitModTree`,
    method: 'GET',
    params,
  });
};

/**
 * 获取模型节点
 */
export const getModeNodeInfo = (params: {
  resId: string;
  resAddre: string;
  nodeIds: string;
}): Promise<any> => {
  return request({
    url: `/api/resource/getModeNodeInfo`,
    method: 'GET',
    params,
  });
};

/**
 * 获取模型节点属性
 */
export const getModeNodeProp = (params: {
  resId: string;
  resAddre: string;
  nodeId: string;
}): Promise<any> => {
  return request({
    url: `/api/resource/getModeNodeProp`,
    method: 'GET',
    params,
  });
};
